package com.wugui.datax.job.mapper.base;

import com.wugui.datax.job.entity.JobDatasource;
import com.wugui.datax.job.service.JobDatasourceService;
import com.wugui.datax.job.tool.query.HiveTemplate;
import com.wugui.datax.job.util.JdbcConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

/**
 * @author luofei
 * @date 2021/6/22 15:29
 */
@Component
public  class HiveMapper  {


    @Autowired
    private JobDatasourceService jobDatasourceService;

    public HiveTemplate hiveTemplate() {
        HiveTemplate hiveTemplate = null;
        if (hiveTemplate==null){
            JobDatasource jobDatasource = jobDatasourceService.getDatasource(JdbcConstants.DATASOURCE_ODS_ID);
            try {
                hiveTemplate = new HiveTemplate(jobDatasource);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return hiveTemplate;
    }
}
